/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package carstoredb.models;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author wuhao
 */
@Entity
@Table(name = "car")
@XmlRootElement
@NamedQueries({
	@NamedQuery(name = "Car.findAll", query = "SELECT c FROM Car c"),
	@NamedQuery(name = "Car.findById", query = "SELECT c FROM Car c WHERE c.id = :id"),
	@NamedQuery(name = "Car.findByFactoryId", query = "SELECT c FROM Car c WHERE c.factoryId = :factoryId"),
	@NamedQuery(name = "Car.findByCarNAME", query = "SELECT c FROM Car c WHERE c.carNAME = :carNAME"),
	@NamedQuery(name = "Car.findByCarSIZE", query = "SELECT c FROM Car c WHERE c.carSIZE = :carSIZE")})
public class Car implements Serializable {

	private static final long serialVersionUID = 1L;
	@Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Basic(optional = false)
        @Column(name = "ID")
	private Integer id;
	@Size(max = 255)
        @Column(name = "FACTORY_ID")
	private String factoryId;
	@Size(max = 255)
        @Column(name = "car_NAME")
	private String carNAME;
	@Size(max = 255)
        @Column(name = "car_SIZE")
	private String carSIZE;
	@OneToMany(mappedBy = "carID")
	private Collection<OrderInfo> orderInfoCollection;
	@OneToMany(mappedBy = "carID")
	private Collection<StoreInfo> storeInfoCollection;
	@OneToMany(mappedBy = "carID")
	private Collection<UserInfo> userInfoCollection;

	public Car() {
	}

	public Car(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getFactoryId() {
		return factoryId;
	}

	public void setFactoryId(String factoryId) {
		this.factoryId = factoryId;
	}

	public String getCarNAME() {
		return carNAME;
	}

	public void setCarNAME(String carNAME) {
		this.carNAME = carNAME;
	}

	public String getCarSIZE() {
		return carSIZE;
	}

	public void setCarSIZE(String carSIZE) {
		this.carSIZE = carSIZE;
	}

	@XmlTransient
	public Collection<OrderInfo> getOrderInfoCollection() {
		return orderInfoCollection;
	}

	public void setOrderInfoCollection(Collection<OrderInfo> orderInfoCollection) {
		this.orderInfoCollection = orderInfoCollection;
	}

	@XmlTransient
	public Collection<StoreInfo> getStoreInfoCollection() {
		return storeInfoCollection;
	}

	public void setStoreInfoCollection(Collection<StoreInfo> storeInfoCollection) {
		this.storeInfoCollection = storeInfoCollection;
	}

	@XmlTransient
	public Collection<UserInfo> getUserInfoCollection() {
		return userInfoCollection;
	}

	public void setUserInfoCollection(Collection<UserInfo> userInfoCollection) {
		this.userInfoCollection = userInfoCollection;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Car)) {
			return false;
		}
		Car other = (Car) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "carstoredb.models.Car[ id=" + id + " ]";
	}
	
}
